package com.example.tijianserver.response;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

//全局异常处理器，能够处理controller service mapper等给出的异常
@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Object handlerException(Exception e){
        return ApiRestResponse.error(TijianExceptionEnum.SYSTEM_ERROR);
    }

    @ExceptionHandler(TijianException.class) //声明只处理体检业务异常
    @ResponseBody
    public Object NeueduMallException(TijianException e){
        return ApiRestResponse.error(e.getStatus(),e.getDesc());
    }

}
